﻿var randNumber1 = Math.floor(Math.random() * 6) + 1;

var randomDiceImage1 = randNumber1 +".jpg";
var randomImageSource1 = "images/" + randomDiceImage1;

var image1 = document.querySelectorAll("img")[0];
image1.setAttribute("src",randomImageSource1);

var randNumber2 = Math.floor(Math.random() * 6) + 1;
var randomDiceImage2 = randNumber2 +".jpg";
var randomImageSource2 = "images/" + randomDiceImage2;

var image2 = document.querySelectorAll("img")[1];
image2.setAttribute("src",randomImageSource2);

if(randNumber1 > randNumber2){
    document.querySelector("h1").innerHTML ="Player 1 Wins";
}else if(randNumber1 < randNumber2){
    document.querySelector("h1").innerHTML ="Player 2 Wins";
}else{
    document.querySelector("h1").innerHTML ="Draw!";
}